﻿
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 
<title>jb-aptech毕业设计项目</TITLE>
<meta name="renderer" content="ie-comp">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link href="../../css/style.css" rel="stylesheet" type="text/css">
	<link rel="stylesheet" href="../../css/menu.css">

	<script src="../../script/jquery-3.3.1.min.js"></script>
	<script src="../../script/common.js"></script>
	<script src="../../../js/bootstrap.min.js"></script>
	<script src="../../../js/vue.js"></script>
</head>
  <body>
  <div id="xiugai">
    <div class="page_title">权限管理 > 用户管理 > 系统用户</div>
    	<input type="hidden" >
    	<div class="button_bar">
	   		<button class="common_button" onclick="help('');">帮助</button>
	   		<button class="common_button" onclick="back();">返回</button>
			<button class="common_button" @click="myAdd();">保存</button>
	   	</div>
	   	<table class="query_form_table">
	   		<tr>
	   			<th>编号</th>
	   			<td>
	   				<input type="text" v-model="usr.usr_id" size="20" readonly="readonly">
	   			</td>
	   			<th>用户名</th>
	   			<td>
	   				<input type="text" v-model="usr.usr_name" @input="bbb()">
					<span id="name"></span>
	   			</td>
	   		</tr>
	   		<tr>
	   			<th>密码</th>
	   			<td><br><br><input type="password" v-model="usr.usr_password">
	   			<br><br></td>
	   			<th>角色</th>
	   			<td>
	   					{{usr.role_name}}<span v-if="usr.role_name==null">未指派</span>
	   			</td>
	   		</tr>
	   		<tr>
	   			<th>状态</th>
	   			<td>
	   					<span v-if="usr.usr_flag==1">正常</span>
						<span v-if="usr.usr_flag==0">禁止</span>
	   			</td>
	   		</tr>
	   	</table>
  </div>
  </body>
<script>
	var name ;
	var app = new Vue({
		el:"#xiugai",
		data:{
			usr:{
                usr_id:'',
                usr_name:'',
                usr_password:'',
                usr_flag:'',
				role_name:'',
			}
		},
		methods:{
            myAdd(){
                if(this.usr.usr_name==''||null){
                    alert("必填项存在空值")
                    return
                }
                if(this.usr.usr_password==''||null){
                    alert("必填项存在空值")
                    return
                }
              $.getJSON("/updateSysUser",this.usr,function (json) {
				  if(json.code==200){
					alert("编辑成功！")
					  location='list.html';
				  }else {
				      alert("服务器异常！！")
				  }
              })
			},
            bbb(){
                $.getJSON("/selectusrname",{"value":this.usr.usr_name},function (json) {
                    document.getElementById("name").innerHTML=json.data.tishi;
                    if(app.usr.usr_name==''){
                        document.getElementById("name").innerHTML="用户名不能为空";
                    }
                    if(app.usr.usr_name==name){
                        document.getElementById("name").innerHTML="";
					}
                });
            }
		},
		created(){
			let id = sessionStorage.getItem("id");
			$.getJSON("/querySysUserById2/"+id,function (json) {
			  //  alert(JSON.stringify(json));
				app.usr=json.data.obj[0];
				name=app.usr.usr_name;
            });
        }
	});
</script>
</html>